package dbc;

import java.sql.Connection;
import java.sql.DriverManager;

import tools.Tool;



public class DataBaseConnection {
	public static final String DBDRIVER = "org.gjt.mm.mysql.Driver";
	public static final String DBURL = "jdbc:mysql://localhost:3406/newmyblog";
	public static final String DBUSER = "root";
	public static final String DBPASS = "951020";
	public static Connection conn;
	
	public DataBaseConnection()
	{
		try
		{
			Class.forName(DBDRIVER);
			
			conn=DriverManager.getConnection(DBURL, DBUSER, DBPASS);
		}
		catch(Exception e)
		{
			Tool.PrintException("databaseConnection", this.getClass().getName());
		}
	}
	public static Connection getConnection()
	{
		try
		{
			conn=DriverManager.getConnection(DBURL, DBUSER, DBPASS);
		}
		catch (Exception e) {
			// TODO: handle exception
			Tool.PrintException("getconnection","DatabaseConnection");
			e.printStackTrace();
		}
		return conn;
		
	}
	public void close(){
		this.close();
	}
}
